<?php
/**
 * Created by Dumitru Russu
 * User: developer
 * Date: 9/14/12
 * Time: 3:06 PM
 * To change this template use File | Settings | File Templates.
 */
class Page_Be_Products_Templates extends Page {
    /**
     * @var Db_Products_Templates
     */
    protected $tableObject;

    function __construct() {

        $this->idTableObject = get('id', 'int');
        $this->classTableObject = 'Db_Products_Templates';
        parent::__construct();
    }

    public function defaultAction() {
        self::$TPL->appendJsFile('admin/templates');
        self::$TPL->setBodyTemplate('list_templates');
        return array(
            'type' => 'display'
        );
    }

	public function loadTemplatesDataAction() {
		$allColumns = array('nr', 't_name', 's_name');
		$searchColumns = array('t_name', 's_name');
        list($searchQuery,$orderBy, $limit) = Utils::getSqlQueriesForPagination($allColumns, $searchColumns, 'Db_Products_Templates', 'getTotalTemplates');
        $allTemplates = Db_Products_Templates::getAllTemplates($limit, $searchQuery, $orderBy);
		self::$TPL->assign('allTemplates', $allTemplates);
		return array(
			'type' => 'encoded_json',
			'content' => self::$TPL->display('json_list_templates', true)
		);
	}
}
